import java.awt.Button;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.awt.PopupMenu;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.*;



//
//This class will manage the buttons at the top of each pane. 
//This class also contains the subscriptions window.
//

public class ButtonManager extends JPanel {
	
	//Sorting Drop-down Menu options
	String [] sortingOptions = {"A-Z", "Latest"};
	
	
	//Sorting Drop-down Menu 
	JComboBox sort = new JComboBox(sortingOptions);
	
	
	//Subscriptions Button
	Button Subscriptions = new Button("Subscriptions");
	
	
	//Refresh Button
	Button Refresh = new Button("Refresh");
	
	
	//Subscriptions Window
	JFrame subWindow = new JFrame("Subscriptions");{
		
	//Test String values for the JList
	String test1 = "User 1";
	String test2 = "User 2";
	String test3 = "User 3";
	String test4 = "User 4";
	String test5 = "User 5";
	
	//List Model
	DefaultListModel Subscriptions = new DefaultListModel();
	Subscriptions.addElement(test1);
	Subscriptions.addElement(test2);
	Subscriptions.addElement(test3);
	Subscriptions.addElement(test4);
	Subscriptions.addElement(test5);
	
	
	JList subList = new JList (Subscriptions);
	subList.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
	subList.setLayoutOrientation(JList.VERTICAL_WRAP);
	subList.setVisibleRowCount(-1);
	
	JScrollPane listScroller = new JScrollPane(subList);
	listScroller.setPreferredSize(new Dimension(300, 450));

	Button unsubscribe = new Button("Unsubscribe");
	unsubscribe.setSize(100, 20);
	
	Button SortByUser = new Button("Sort By User");
	SortByUser.setSize(100, 20);
	
	JTextField newSubscription = new JTextField(15);
	
	Button AddSub = new Button("Subscribe");
	SortByUser.setSize(100, 20);
	
	
	Dimension boxSize = new Dimension(300,60);
	
	
	JPanel ButtonBox = new JPanel ();
	ButtonBox.setPreferredSize(boxSize);
	ButtonBox.add(SortByUser);
	ButtonBox.add(unsubscribe);
	ButtonBox.add(newSubscription);
	ButtonBox.add(AddSub);
	

	subWindow.setSize(350,560);
	subWindow.setLocation(0, 0);
	subWindow.setVisible(false);
	subWindow.setLayout(new FlowLayout());
	subWindow.add(ButtonBox);
	subWindow.add(listScroller);
	
	}
	
	
	Dimension buttonMaximumSize = new Dimension(300,70);
	
	public ButtonManager (){
		
		
		
		
		
		add(sort);
		
		
		add(Subscriptions);
		Subscriptions.addActionListener(
				
				new ActionListener() {

					public void actionPerformed(ActionEvent e) {
						subWindow.setVisible(true);
					}
					
				}
		);
		
		
		add(Refresh);
		
	
	
		setMaximumSize(buttonMaximumSize);
		setBorder(BorderFactory.createLineBorder(Color.RED));
	}
	

}
